<%@ page language="java" contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
    <base href="<%=basePath%>">
    <title>印刷企业管理系统</title>
    <meta http-equiv="Pragma" CONTENT="no-cache">
    <meta http-equiv="Cache-Control" CONTENT="no-cache">
    <meta http-equiv="Expires" CONTENT="0">
    <meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
	<link href="docs/login/img/main.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
	function login(){
		var loginid=document.getElementById("txtloginid");
		var password=document.getElementById("txtPassword");
		if(loginid.value==""){
			alert("用户名不能为空！");
			loginid.focus();
			return ;
		}else if(password.value==""){
			alert("密码不能为空！");
			password.focus();
			return ;
		}
		sendRequest(loginid.value,password.value);
	}
	var xmlHttpRequest;
	function sendRequest(loginid,password){
		if(window.ActiveXObject){
			xmlHttpRequest= new ActiveXObject("Microsoft.XMLHTTP");
		}else if(window.XMLHttpRequest){
			xmlHttpRequest= new XMLHttpRequest();
		}
		var url="<%=request.getContextPath()%>/doLogin.action?user.loginid="+ encodeURI(loginid) + "&user.password=" + encodeURI(password);
		xmlHttpRequest.open("post", url, true);
		xmlHttpRequest.onreadystatechange = resultSet;
		xmlHttpRequest.send(null);
	}
	function resultSet() {
		if (xmlHttpRequest.readyState == 4 && xmlHttpRequest.status == 200) {
			var rs = xmlHttpRequest.responseText;
			if("success"==rs){
				window.location.href='<%=request.getContextPath()%>/main.action';
			}else{
				alert(rs);
			}
		}
	}
	function checkKey(){
		if(event.keyCode==13){
			login();
		}
	}
</script>
</head>

<body class="login_bg" >
<form action="" method="post" id="logF">
<table border="0" cellpadding="0" cellspacing="0" class="login_table">
  <tr>
    <td><input type="hidden" name="flag" value="false"/>
    <table width="800" height="289" border="0" align="center" cellpadding="0" cellspacing="0">
      <tr>
        <td><table width="800" height="130" border="0" align="center" cellpadding="0" cellspacing="0">
          <tr>
            <td rowspan="4">&nbsp;</td>
            <td height="100">&nbsp;</td>
            <td align="right">&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
          </tr>
          <tr>
          	<td rowspan="2" align="center">&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td height="50" rowspan="2" align="center"><img src="docs/login/img/use.png" width="32" height="48"></td>
            <td>用户名</td>
            <td>&nbsp;</td>
            <td rowspan="2" align="center"><img src="docs/login/img/mm.png" width="40" height="49"></td>
            <td>密码</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td rowspan="2"><input name="button" type="button" class="login_btn" id="button" value=" " onclick="login();"></td>
          </tr>
          <tr>
          	<td width="80"><input type="hidden" value="zp" name="scr" id="scr"></td>
            <td></td>
            <td><input name="user.loginid" id="txtloginid" type="text" class="text" maxlength="20" style="width: 150" value="ningjie" onkeyup="checkKey()"/></td>
            <td>&nbsp;</td>
            <td><input name="user.password" id="txtPassword" type="password" class="text" maxlength="20" style="width:150" value="nj888" onkeyup="checkKey()"/></td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            </tr>
          <tr>
            <td height="50" align="center">&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td align="center">&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td align="center">&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
          </tr>
        </table>
          </td>
      </tr>
    </table>
    </td>
  </tr>
</table>
</form>
</body>
</html>
